import { profile } from "../../../../js/modules/store.js";
import { forms, storage, util } from '../../../../js/util';
import authorize from '../../../../js/modules/authorize.js'
import BasePage from '../../../../js/common/base-page'
BasePage({
  pageKey:"wxAccountList",

  /**
   * 页面的初始数据
   */
  data: {
    list: [
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //判断是否登录
    if (!authorize.isLogin('store')) {
      authorize.redirect('store');
      return;
    }

  },

  /**加载商品列表 */
  loadList() {
    var that = this;
    var page=this.data.page;
    profile.load_wx_account(function (content) {
      that.setData({
        list: content,
        isLoadComplete: true
      });

    });
  },
  /**
   * 切换开关
   */
  onSwitchEvent:function(e){
    var index = e.currentTarget.dataset.index;
    var id = this.data.list[index].Id;
    var value=e.detail.value;
    var that=this;
    profile.set_is_receivemsg(id,function (res) {
      if(res.Success){
        that.data.list[index].IsReceiveMsg = (value?1:0);
      }
      that.setData({
        list: that.data.list
      });

    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.loadList();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})